#include "StdAfx.h"
#include ".\gamelobbyroom.h"
#include "Player.h"
#include "Party.h"

__IMPL_GAMEZONEPOOL(GameLobbyRoom)
GameLobbyRoom::GameLobbyRoom(void)
{
	m_pPartyHashTable = new util::SolarHashTable<Party*>;
	m_pPartyHashTable->Initialize( 1 );
}

GameLobbyRoom::~GameLobbyRoom(void)
{
	SAFE_DELETE(m_pPartyHashTable);
}
VOID GameLobbyRoom::Init( KEYTYPE Key, CODETYPE MapCode, const TCHAR * pszRoomTitle, const TCHAR * pszRoomPWD, const BASE_ROOMINFO * IN pRoomInfo )
{
	GameRoom::Init( Key, MapCode, pszRoomTitle, pszRoomPWD, pRoomInfo );
	
	GameZone::LoadMap();
}

VOID GameLobbyRoom::Ready( Player * pPlayer, CODETYPE FieldCode, WzID AreaID )
{
	DEBUG_CODE(
		GameZone * pEnterZone	= NULL;
	CODETYPE EnterFieldCode	= 0;
	eZONE_STATE eRoomState	= pPlayer->GetGameZone( pEnterZone, EnterFieldCode );
	ASSERT( !(eRoomState & ePRS_AT_ZONE) );
	);


	pPlayer->SetGameZone( ePRS_BEFORE_ENTER_LOBBY, this, FieldCode, AreaID );
}


BOOL GameLobbyRoom::Join( Player * pPlayer, CODETYPE FieldCode, WzID AreaID )
{
	DEBUG_CODE(
		GameZone * pEnterZone		= NULL;
	CODETYPE EnterFieldCode = 0;
	eZONE_STATE eRoomState	= pPlayer->GetGameZone( pEnterZone, EnterFieldCode );
	ASSERT( (eRoomState & ePRS_BEFORE_ENTER_LOBBY) );
	);

	pPlayer->SetGameZone( ePRS_AT_LOBBY, this, FieldCode );

	if( !GameRoom::Join( pPlayer, FieldCode, AreaID ) )
	{
		pPlayer->SetGameZone( ePRS_NOT_AT_ZONE, NULL, 0 );
		return FALSE;
	}

	return TRUE;
}
BOOL GameLobbyRoom::CheckMapVersion( CODETYPE FieldCode, DWORD checksum )
{
	return TRUE;
}


VOID GameLobbyRoom::Update( DWORD dwDeltaTick )
{
	
}